package com.yy.wga.mp.module.business.controller;


import com.yy.wga.business.feign.controller.BusinessCourseFeign;
import com.yy.wga.common.core.dto.Result;
import com.yy.wga.common.utils.mapping.BeansUtils;
import com.yy.wga.mp.module.business.response.BusinessCourseInfoResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商学院课程
 *
 * @author guochao
 * @since 2025-02-09 15:18:37
 */
@RestController
@RequestMapping("/api/business/course")
public class BusinessCourseController {
    /**
     * 服务对象
     */
    @Resource
    private BusinessCourseFeign businessCourseFeign;

    /**
     * 获取课程列表
     * @return
     */
    @PostMapping("list")
    public Result<List<BusinessCourseInfoResponse>> page() {
        Result<List<com.yy.wga.business.feign.response.BusinessCourseInfoResponse>> result = businessCourseFeign.page();
        if (result.isSuccess()) {
            List<com.yy.wga.business.feign.response.BusinessCourseInfoResponse> data = result.getData();
            List<BusinessCourseInfoResponse> pageBean = BeansUtils.mapList(data, BusinessCourseInfoResponse.class);
            return Result.success(pageBean);
        }
        return Result.fail(result.getCode(), result.getMessage());
    }
}
